import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:十字爆破
 * User: wangxin
 * Date: 2024-08-03
 * Time: 16:56
 */
public class test {


    // 注意类名必须为 Main, 不要有任何 package xxx 信息

        public static int func1(int[][] arr,int i,int j){
            if(i < 0){
                return 0;
            }
            return arr[i][j] + func1(arr,i - 1,j);
        }
        public static int func2(int[][] arr,int i,int j){
            if(i >= arr.length){
                return 0;
            }
            return arr[i][j] + func2(arr,i+1,j);
        }
        public static int func3(int[][] arr,int i,int j){
            if(j < 0){
                return 0;
            }
            return arr[i][j] + func3(arr,i ,j- 1);
        }
        public static int func4(int[][] arr,int i,int j){
            if(j >= arr[0].length){
                return 0;
            }
            return arr[i][j] + func4(arr,i,j+1);
        }

        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            // 注意 hasNext 和 hasNextLine 的区别

            int n = in.nextInt();
            int m = in.nextInt();
            int[][] arr = new int[n][m];
            for(int i = 0;i < arr.length;i++){
                for(int j = 0;j < arr[i].length;j++){
                    arr[i][j] = in.nextInt();
                }
            }
            int[][] arr1 =  new int[n][m];
            for(int i = 0;i < arr1.length;i++){
                for(int j = 0;j < arr1[i].length;j++){
                    int a = 0,b = 0,c = 0,d = 0;
                    if(i - 1 >= 0){
                        a = func1(arr,i - 1,j);
                    }
                    if(i + 1 < arr.length){
                        b = func2(arr,i + 1,j);
                    }
                    if(j - 1 >= 0){
                        c = func3(arr,i ,j- 1);
                    }
                    if(j + 1 < arr[i].length){
                        d = func4(arr,i ,j+ 1);
                    }
                    arr1[i][j] = arr[i][j] + a + b + c + d;
                }

            }
            for(int i = 0;i < arr1.length;i++){
                for(int j = 0;j < arr1[i].length;j++){
                    System.out.println(arr1[i][j]);
                }
            }

        }


}
